Skip to content

feat: multi-tab simultaneous diffs for multi-file edits#37

Merged
Cannon07 merged 1 commit intomainfrom
feat/multi-tab-diff
Apr 17, 2026
Merged

feat: multi-tab simultaneous diffs for multi-file edits#37
Cannon07 merged 1 commit intomainfrom
feat/multi-tab-diff

Conversation

@Cannon07
Copy link
Copy Markdown
Owner

@Cannon07 Cannon07 commented Apr 17, 2026

Summary

  • Multi-tab diffs: Each file edit opens its own diff tab instead of queuing. Solves OpenCode's multi-file workflow where all before-hooks fire before any after-hooks, causing only the last file's diff to appear.
  • Per-PID temp files: Prevents collision between concurrent hook processes (claude-diff-original-$$).
  • Neo-tree stale tabpage fix: Defers neo_tree.refresh() to after tab close via vim.schedule(), preventing Invalid tabpage id errors.
  • New file visibility: Delayed second refresh ensures newly created files appear in neo-tree after the backend writes them to disk.
  • apply-edit.lua fix: Empty old_string now correctly prepends new_string (handles new file creation via OpenCode).

Test plan

  • All 18 Plenary unit tests pass (6 changes registry + 12 diff lifecycle)
  • All 22 backend shell tests pass
  • Manual: single-file Edit/Write with Claude Code — diff opens and closes on accept
  • Manual: multi-file edit with OpenCode — both tabs open simultaneously, close independently
  • Manual: new file creation — neo-tree shows created icon, file appears after accept
  • Manual: all three layouts (tab, vsplit, inline) work correctly

Replace the single-diff-with-queue architecture with multi-tab simultaneous
diffs. Each file edit now opens its own tab, solving OpenCode's multi-file
workflow where all before-hooks fire before any after-hooks.

Key changes:
- diff.lua: active_diffs table keyed by file path replaces single diff_tab
- diff.lua: per-buffer inline state (buf_inline_data) replaces module-level vars
- diff.lua: close_for_file(path) closes specific file's diff tab
- diff.lua: neo-tree refresh deferred to after tab close (fixes stale tabpage crash)
- diff.lua: delayed second refresh so new files appear in neo-tree after write
- core-post-tool.sh: uses close_for_file(path) instead of is_open() + close_diff()
- core-pre-tool.sh: per-PID temp files prevent collision between concurrent hooks
- core-pre-tool.sh: neo-tree indicator/reveal moved to Lua side (mark_change_and_reveal)
- apply-edit.lua: fix empty old_string handling for new file creation
- Remove dead auto_close config option (no longer applicable with multi-tab)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Cannon07 Cannon07 merged commit 561660d into main Apr 17, 2026
2 checks passed
@Cannon07 Cannon07 deleted the feat/multi-tab-diff branch April 17, 2026 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant